473,529 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing 'selected' Option in Select Dropdown before Submit

I use a SELECT dropdown as the nav interface for jumping to a chosen
page number. When I setup up the SELECT element on the page, I want to
show the user the current page number they are on, so, I put "selected"
next to the page number, as shown below:

-------------------------------

<form name="pick" method="post" action="showit.php">
<select name="pggo"
onChange="this.options[this.selectedIndex].selected;document.pick.submit();">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
</form>

-------------------------------

The problem is that no matter what page number is chosen from the
dropdown, the passed value is always "2", because that's the "selected"
value above.

Is there any Javascript that I can add to the onChange statement above
that will change the 'selected' value from the current page number to
the one chosen by the user? I've tried a bunch of things, but, 2 is the
value that seems to always get passed. I'm not sure how to change the
selected value to the one chosen from the dropdown. Am I close with the
above code, or way off base?

Any help is much appreciated! I've spent about 4 hours searching and
trying to find out how to do this, but, nothing seems to work. Maybe
it's not possible?

Thanks.

Nov 23 '05 #1
2 8056

Your plight seem to be with PHP, not with js, so, check in your PHP
script instead.

Danny
Nov 23 '05 #2
On 2005-11-20, Monty <mo****@hotmail.com> wrote:
I use a SELECT dropdown as the nav interface for jumping to a chosen
page number. When I setup up the SELECT element on the page, I want to
show the user the current page number they are on, so, I put "selected"
next to the page number, as shown below:

-------------------------------

<form name="pick" method="post" action="showit.php">
<select name="pggo"
onChange="this.options[this.selectedIndex].selected;document.pick.submit();">
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
</form>

-------------------------------

The problem is that no matter what page number is chosen from the
dropdown, the passed value is always "2", because that's the "selected"
value above.
Add onchange to each of the options?

aboce you say:
this.options[this.selectedIndex].selected


this part does nothing, what is it supposed to do?

Bye.
Jasen
Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
77301
by: London | last post by:
Hello Can you help me. By ASP How can I get the dropdown(control'name)'s selected value? What is it's property'name?
8
10195
by: Lisa | last post by:
I have a drop down that defaults to "select" after the page refreshes. How do I keep the selected value in the dropdown field... I've tried EVERYTHING and nothing works! :( <script LANGUAGE="JavaScript"> function getServer(form){ var cdoServerName = document.frmSoftware.cdoServerName.options.value;
2
2103
by: John Ryan | last post by:
I've a small bit of javascript on my site that has a from with 2 selection boxes, when you choose an option in the first box, the second one re-populates its list accordingly. But the second selection box can have varying amounts of entries, and this means theres a lot of white spaces in the second selection box sometimes. Is there any way...
4
6287
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by the choice from the drop down box. Something like: <form name="populatefrm" id="contactfrm" method="post"
1
25708
by: acord | last post by:
Hi, I am having problem to get a value of the selected item from a dropdown listbox. Here is the JS function; function getSelectedItem(objSelect) { alert("in getSelectedItem"); alert (objSelect.length); alert (objSelect.value);
7
2405
by: brendan.wong | last post by:
hello. i have a really simple form that asks the user to select a Month from a dropdown. the first time a user visits the page, the highlighted option should be October, which works fine. then, if the user submits the form, i want the dropdown to highlight whatever selection that the user made in the resulting page. for example, if the...
1
1720
by: roland-d | last post by:
Hello all, Toggling divs is a popular subject and I have found plenty of information and was able to make it work. There is only 1 thing I am still stuck with for quite some time. I have a dropdown menu and when I select a date from this menu it displays another select box with times for that day. When I select another date another...
1
5057
by: sparksol | last post by:
I have a form with a drop down box. If you select an option in the drop down box (depending which option is selected) one or two textbox(es) and a submit button display. I would like to keep the textbox(es) and the submit button showing until another option is selected. Also the data that's submitted is showing on the form page. Here's an...
1
7659
by: ghjk | last post by:
I want to take the drop down selected value using javascript. This is dropdown code <select id="user"> <option >Admin</option> <option >User</option> <option >Guest</option> </select>
0
7258
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7661
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7244
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5790
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4826
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3321
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3322
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
894
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
558
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.